/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.loja.view.swing;

import java.util.Arrays;
import javax.swing.AbstractButton;
import javax.swing.JDesktopPane;
import br.com.loja.controller.MainDesktopFramePresenter;
import br.com.loja.util.i18n.Language;

/**
 *
 * @author CASA
 */
public class MainDesktopFrame extends javax.swing.JFrame {

    /**
     * Creates new form MainDesktopFrame
     */
    public MainDesktopFrame() {
        initComponents();
        settingListeners();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        desktopPane = new javax.swing.JDesktopPane();
        painelFixo = new javax.swing.JPanel();
        toolBarFixo = new javax.swing.JToolBar();
        btNovaVenda = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        btMenuArquivo = new javax.swing.JMenu();
        btMenuItemSair = new javax.swing.JMenuItem();
        btMenuEstoque = new javax.swing.JMenu();
        btMenuItemEstoque = new javax.swing.JMenu();
        btMenuItemItensEstoque = new javax.swing.JMenuItem();
        jSeparator9 = new javax.swing.JPopupMenu.Separator();
        btMenuItemAlteracaoEstoque = new javax.swing.JMenuItem();
        btMenuProduto = new javax.swing.JMenu();
        btMenuItemProdutos = new javax.swing.JMenuItem();
        btMenuItemCategorias = new javax.swing.JMenuItem();
        btMenuItemGrupos = new javax.swing.JMenuItem();
        btMenuFinanceiro = new javax.swing.JMenu();
        btMenuCompra = new javax.swing.JMenu();
        btMenuItemItensPedidoCompra = new javax.swing.JMenuItem();
        btMenuItemPedidosCompra = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        btMenuItemIncluirCompra = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        btMenuItemCartoesCreditoCompra = new javax.swing.JMenuItem();
        btMenuDespesa = new javax.swing.JMenu();
        btMenuItemDespesas = new javax.swing.JMenuItem();
        jSeparator6 = new javax.swing.JPopupMenu.Separator();
        btMenuItemIncluirPagamentoDespesa = new javax.swing.JMenuItem();
        btMenuItemReceitas = new javax.swing.JMenuItem();
        btMenuItemCaixas = new javax.swing.JMenuItem();
        btMenuOperadora = new javax.swing.JMenu();
        btMenuItemOperadoras = new javax.swing.JMenuItem();
        btMenuItemCartoesAceitos = new javax.swing.JMenuItem();
        jSeparator4 = new javax.swing.JPopupMenu.Separator();
        btMenuItemResgatarCreditos = new javax.swing.JMenuItem();
        btMenuConta = new javax.swing.JMenu();
        btMenuItemContas = new javax.swing.JMenuItem();
        jSeparator7 = new javax.swing.JPopupMenu.Separator();
        btMenuItemIncluirTransferencia = new javax.swing.JMenuItem();
        btMenuItemIncluirReceita = new javax.swing.JMenuItem();
        btMenuItemIncluirDespesa = new javax.swing.JMenuItem();
        btMenuPDV = new javax.swing.JMenu();
        btMenuItemNovaVenda = new javax.swing.JMenuItem();
        btMenuItemEstornarVenda = new javax.swing.JMenuItem();
        btMenuCliente = new javax.swing.JMenu();
        btMenuItemClientes = new javax.swing.JMenuItem();
        jSeparator10 = new javax.swing.JPopupMenu.Separator();
        btMenuItemConsultarExtrato = new javax.swing.JMenuItem();
        btMenuItemIncluirPagamento = new javax.swing.JMenuItem();
        btMenuItemIncluirCreditos = new javax.swing.JMenuItem();
        btMenuFerramentas = new javax.swing.JMenu();
        btMenuTarefa = new javax.swing.JMenu();
        btMenuItemTarefas = new javax.swing.JMenuItem();
        jSeparator8 = new javax.swing.JPopupMenu.Separator();
        btMenuItemAgendadorTarefas = new javax.swing.JMenuItem();
        btMenuUsuario = new javax.swing.JMenu();
        btMenuItemUsuarios = new javax.swing.JMenuItem();
        btMenuItemPermissoes = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        btMenuItemConfiguracoes = new javax.swing.JMenuItem();
        btMenuConexao = new javax.swing.JMenu();
        btMenuItemTestarConexao = new javax.swing.JMenuItem();
        jSeparator5 = new javax.swing.JPopupMenu.Separator();
        btMenuItemAjuda = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Loja WebApp - 2014");
        setMinimumSize(new java.awt.Dimension(800, 600));
        setName("mainDesktop"); // NOI18N
        setPreferredSize(new java.awt.Dimension(800, 600));

        desktopPane.setBackground(java.awt.SystemColor.textInactiveText);

        javax.swing.GroupLayout desktopPaneLayout = new javax.swing.GroupLayout(desktopPane);
        desktopPane.setLayout(desktopPaneLayout);
        desktopPaneLayout.setHorizontalGroup(
            desktopPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 583, Short.MAX_VALUE)
        );
        desktopPaneLayout.setVerticalGroup(
            desktopPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 463, Short.MAX_VALUE)
        );

        toolBarFixo.setFloatable(false);
        toolBarFixo.setRollover(true);

        btNovaVenda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/img/Deep_Shoppingcart.png"))); // NOI18N
        btNovaVenda.setText("Nova Venda");
        btNovaVenda.setActionCommand("novaVenda");
        btNovaVenda.setFocusable(false);
        btNovaVenda.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btNovaVenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btNovaVendaActionPerformed(evt);
            }
        });
        toolBarFixo.add(btNovaVenda);

        javax.swing.GroupLayout painelFixoLayout = new javax.swing.GroupLayout(painelFixo);
        painelFixo.setLayout(painelFixoLayout);
        painelFixoLayout.setHorizontalGroup(
            painelFixoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(toolBarFixo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        painelFixoLayout.setVerticalGroup(
            painelFixoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(toolBarFixo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        btMenuArquivo.setText(language.getString("file"));

        btMenuItemSair.setText("Sair");
        btMenuItemSair.setActionCommand("sair");
        btMenuArquivo.add(btMenuItemSair);

        menuBar.add(btMenuArquivo);

        btMenuEstoque.setText(language.getString("stock"));

        btMenuItemEstoque.setText("Estoque");

        btMenuItemItensEstoque.setText("Itens em estoque...");
        btMenuItemItensEstoque.setActionCommand("itensEstoque");
        btMenuItemEstoque.add(btMenuItemItensEstoque);
        btMenuItemEstoque.add(jSeparator9);

        btMenuItemAlteracaoEstoque.setText("Incluir alteração em estoque");
        btMenuItemAlteracaoEstoque.setActionCommand("alteracaoEstoque");
        btMenuItemEstoque.add(btMenuItemAlteracaoEstoque);

        btMenuEstoque.add(btMenuItemEstoque);

        btMenuProduto.setText("Produto");

        btMenuItemProdutos.setText("Produtos...");
        btMenuItemProdutos.setActionCommand("produtos");
        btMenuProduto.add(btMenuItemProdutos);

        btMenuItemCategorias.setText("Categorias...");
        btMenuItemCategorias.setActionCommand("categorias");
        btMenuProduto.add(btMenuItemCategorias);

        btMenuItemGrupos.setText("Grupo...");
        btMenuItemGrupos.setActionCommand("grupos");
        btMenuProduto.add(btMenuItemGrupos);

        btMenuEstoque.add(btMenuProduto);

        menuBar.add(btMenuEstoque);

        btMenuFinanceiro.setText(language.getString("financial"));

        btMenuCompra.setText("Compra");

        btMenuItemItensPedidoCompra.setText("Itens pedido de compra...");
        btMenuItemItensPedidoCompra.setActionCommand("itensPedidoCompra...");
        btMenuCompra.add(btMenuItemItensPedidoCompra);

        btMenuItemPedidosCompra.setText("Pedidos de compra...");
        btMenuItemPedidosCompra.setActionCommand("pedidosCompra...");
        btMenuCompra.add(btMenuItemPedidosCompra);
        btMenuCompra.add(jSeparator2);

        btMenuItemIncluirCompra.setText("Incluir compra");
        btMenuItemIncluirCompra.setActionCommand("incluirCompra");
        btMenuCompra.add(btMenuItemIncluirCompra);
        btMenuCompra.add(jSeparator1);

        btMenuItemCartoesCreditoCompra.setText("Cartões de crédito para compra...");
        btMenuItemCartoesCreditoCompra.setActionCommand("cartoesCreditoCompra");
        btMenuCompra.add(btMenuItemCartoesCreditoCompra);

        btMenuFinanceiro.add(btMenuCompra);

        btMenuDespesa.setText("Despesa");

        btMenuItemDespesas.setText("Despesas...");
        btMenuItemDespesas.setActionCommand("despesas");
        btMenuDespesa.add(btMenuItemDespesas);
        btMenuDespesa.add(jSeparator6);

        btMenuItemIncluirPagamentoDespesa.setText("Incluir pagamento de despesa");
        btMenuItemIncluirPagamentoDespesa.setActionCommand("incluirPagamentoDespesa");
        btMenuDespesa.add(btMenuItemIncluirPagamentoDespesa);

        btMenuFinanceiro.add(btMenuDespesa);

        btMenuItemReceitas.setText("Receitas...");
        btMenuItemReceitas.setActionCommand("receitas");
        btMenuFinanceiro.add(btMenuItemReceitas);

        btMenuItemCaixas.setText("Caixas...");
        btMenuItemCaixas.setActionCommand("caixas");
        btMenuFinanceiro.add(btMenuItemCaixas);

        btMenuOperadora.setText("Operadora de Cartão");

        btMenuItemOperadoras.setText("Operadoras...");
        btMenuItemOperadoras.setActionCommand("operadoras");
        btMenuOperadora.add(btMenuItemOperadoras);

        btMenuItemCartoesAceitos.setText("Cartões aceitos...");
        btMenuItemCartoesAceitos.setActionCommand("cartoesAceitos");
        btMenuOperadora.add(btMenuItemCartoesAceitos);
        btMenuOperadora.add(jSeparator4);

        btMenuItemResgatarCreditos.setText("Resgatar créditos");
        btMenuItemResgatarCreditos.setActionCommand("resgatarCreditos");
        btMenuOperadora.add(btMenuItemResgatarCreditos);

        btMenuFinanceiro.add(btMenuOperadora);

        btMenuConta.setText("Conta");

        btMenuItemContas.setText("Contas...");
        btMenuItemContas.setActionCommand("contas");
        btMenuConta.add(btMenuItemContas);
        btMenuConta.add(jSeparator7);

        btMenuItemIncluirTransferencia.setText("Incluir transferência entre contas");
        btMenuItemIncluirTransferencia.setActionCommand("incluirTransferencia");
        btMenuConta.add(btMenuItemIncluirTransferencia);

        btMenuItemIncluirReceita.setText("Incluir receita diversa");
        btMenuItemIncluirReceita.setActionCommand("incluirReceita");
        btMenuConta.add(btMenuItemIncluirReceita);

        btMenuItemIncluirDespesa.setText("Incluir despesa diversa");
        btMenuItemIncluirDespesa.setActionCommand("incluirDespesa");
        btMenuConta.add(btMenuItemIncluirDespesa);

        btMenuFinanceiro.add(btMenuConta);

        menuBar.add(btMenuFinanceiro);

        btMenuPDV.setText(language.getString("pos"));

        btMenuItemNovaVenda.setText("Nova Venda");
        btMenuItemNovaVenda.setActionCommand("novaVenda");
        btMenuPDV.add(btMenuItemNovaVenda);

        btMenuItemEstornarVenda.setText("Estornar Venda");
        btMenuItemEstornarVenda.setActionCommand("estornarVenda");
        btMenuPDV.add(btMenuItemEstornarVenda);

        menuBar.add(btMenuPDV);

        btMenuCliente.setText(language.getString("client"));

        btMenuItemClientes.setText("Clientes...");
        btMenuItemClientes.setActionCommand("clientes");
        btMenuCliente.add(btMenuItemClientes);
        btMenuCliente.add(jSeparator10);

        btMenuItemConsultarExtrato.setText("Consultar extrato");
        btMenuItemConsultarExtrato.setActionCommand("consultarExtrato");
        btMenuCliente.add(btMenuItemConsultarExtrato);

        btMenuItemIncluirPagamento.setText("Incluir pagamento");
        btMenuItemIncluirPagamento.setActionCommand("incluirPagamento");
        btMenuCliente.add(btMenuItemIncluirPagamento);

        btMenuItemIncluirCreditos.setText("Incluir crédito");
        btMenuItemIncluirCreditos.setActionCommand("IncluirCredito");
        btMenuCliente.add(btMenuItemIncluirCreditos);

        menuBar.add(btMenuCliente);

        btMenuFerramentas.setText(language.getString("tools"));

        btMenuTarefa.setText("Tarefa");

        btMenuItemTarefas.setText("Tarefas...");
        btMenuItemTarefas.setActionCommand("tarefas");
        btMenuTarefa.add(btMenuItemTarefas);
        btMenuTarefa.add(jSeparator8);

        btMenuItemAgendadorTarefas.setText("Agendador de Tarefas");
        btMenuItemAgendadorTarefas.setActionCommand("agendadorTarefas");
        btMenuTarefa.add(btMenuItemAgendadorTarefas);

        btMenuFerramentas.add(btMenuTarefa);

        btMenuUsuario.setText("Usuário");

        btMenuItemUsuarios.setText("Usuários...");
        btMenuItemUsuarios.setActionCommand("usuarios");
        btMenuUsuario.add(btMenuItemUsuarios);

        btMenuItemPermissoes.setText("Permissões...");
        btMenuItemPermissoes.setActionCommand("permissoes");
        btMenuUsuario.add(btMenuItemPermissoes);

        btMenuFerramentas.add(btMenuUsuario);
        btMenuFerramentas.add(jSeparator3);

        btMenuItemConfiguracoes.setText("Configurações...");
        btMenuItemConfiguracoes.setActionCommand("configuracoes");
        btMenuFerramentas.add(btMenuItemConfiguracoes);

        btMenuConexao.setText("Conexão SGBD");

        btMenuItemTestarConexao.setText("Testar Conexão");
        btMenuItemTestarConexao.setActionCommand("testarConexao");
        btMenuConexao.add(btMenuItemTestarConexao);

        btMenuFerramentas.add(btMenuConexao);
        btMenuFerramentas.add(jSeparator5);

        btMenuItemAjuda.setText("Ajuda");
        btMenuItemAjuda.setActionCommand("ajuda");
        btMenuFerramentas.add(btMenuItemAjuda);

        menuBar.add(btMenuFerramentas);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane)
            .addComponent(painelFixo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(painelFixo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(desktopPane))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btNovaVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btNovaVendaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btNovaVendaActionPerformed

    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu btMenuArquivo;
    private javax.swing.JMenu btMenuCliente;
    private javax.swing.JMenu btMenuCompra;
    private javax.swing.JMenu btMenuConexao;
    private javax.swing.JMenu btMenuConta;
    private javax.swing.JMenu btMenuDespesa;
    private javax.swing.JMenu btMenuEstoque;
    private javax.swing.JMenu btMenuFerramentas;
    private javax.swing.JMenu btMenuFinanceiro;
    private javax.swing.JMenuItem btMenuItemAgendadorTarefas;
    private javax.swing.JMenuItem btMenuItemAjuda;
    private javax.swing.JMenuItem btMenuItemAlteracaoEstoque;
    private javax.swing.JMenuItem btMenuItemCaixas;
    private javax.swing.JMenuItem btMenuItemCartoesAceitos;
    private javax.swing.JMenuItem btMenuItemCartoesCreditoCompra;
    private javax.swing.JMenuItem btMenuItemCategorias;
    private javax.swing.JMenuItem btMenuItemClientes;
    private javax.swing.JMenuItem btMenuItemConfiguracoes;
    private javax.swing.JMenuItem btMenuItemConsultarExtrato;
    private javax.swing.JMenuItem btMenuItemContas;
    private javax.swing.JMenuItem btMenuItemDespesas;
    private javax.swing.JMenu btMenuItemEstoque;
    private javax.swing.JMenuItem btMenuItemEstornarVenda;
    private javax.swing.JMenuItem btMenuItemGrupos;
    private javax.swing.JMenuItem btMenuItemIncluirCompra;
    private javax.swing.JMenuItem btMenuItemIncluirCreditos;
    private javax.swing.JMenuItem btMenuItemIncluirDespesa;
    private javax.swing.JMenuItem btMenuItemIncluirPagamento;
    private javax.swing.JMenuItem btMenuItemIncluirPagamentoDespesa;
    private javax.swing.JMenuItem btMenuItemIncluirReceita;
    private javax.swing.JMenuItem btMenuItemIncluirTransferencia;
    private javax.swing.JMenuItem btMenuItemItensEstoque;
    private javax.swing.JMenuItem btMenuItemItensPedidoCompra;
    private javax.swing.JMenuItem btMenuItemNovaVenda;
    private javax.swing.JMenuItem btMenuItemOperadoras;
    private javax.swing.JMenuItem btMenuItemPedidosCompra;
    private javax.swing.JMenuItem btMenuItemPermissoes;
    private javax.swing.JMenuItem btMenuItemProdutos;
    private javax.swing.JMenuItem btMenuItemReceitas;
    private javax.swing.JMenuItem btMenuItemResgatarCreditos;
    private javax.swing.JMenuItem btMenuItemSair;
    private javax.swing.JMenuItem btMenuItemTarefas;
    private javax.swing.JMenuItem btMenuItemTestarConexao;
    private javax.swing.JMenuItem btMenuItemUsuarios;
    private javax.swing.JMenu btMenuOperadora;
    private javax.swing.JMenu btMenuPDV;
    private javax.swing.JMenu btMenuProduto;
    private javax.swing.JMenu btMenuTarefa;
    private javax.swing.JMenu btMenuUsuario;
    private javax.swing.JButton btNovaVenda;
    private javax.swing.JDesktopPane desktopPane;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator10;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JPopupMenu.Separator jSeparator4;
    private javax.swing.JPopupMenu.Separator jSeparator5;
    private javax.swing.JPopupMenu.Separator jSeparator6;
    private javax.swing.JPopupMenu.Separator jSeparator7;
    private javax.swing.JPopupMenu.Separator jSeparator8;
    private javax.swing.JPopupMenu.Separator jSeparator9;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JPanel painelFixo;
    private javax.swing.JToolBar toolBarFixo;
    // End of variables declaration//GEN-END:variables

    private final MainDesktopFramePresenter presenter = new MainDesktopFramePresenter(this);
    private final Language language = Language.getInstance();

    private void settingListeners() {
        for (AbstractButton menuItem : Arrays.asList(getMenuItens())) {
            menuItem.addActionListener(presenter);
        }

    }

    private AbstractButton[] getMenuItens() {
        AbstractButton itens[] = {
            btMenuItemAgendadorTarefas,
            btMenuItemAjuda,
            btMenuItemAlteracaoEstoque,
            btMenuItemCaixas,
            btMenuItemCartoesAceitos,
            btMenuItemCartoesCreditoCompra,
            btMenuItemCategorias,
            btMenuItemClientes,
            btMenuItemConfiguracoes,
            btMenuItemConsultarExtrato,
            btMenuItemContas,
            btMenuItemDespesas,
            btMenuItemEstornarVenda,
            btMenuItemGrupos,
            btMenuItemIncluirCompra,
            btMenuItemIncluirCreditos,
            btMenuItemIncluirDespesa,
            btMenuItemIncluirPagamento,
            btMenuItemIncluirPagamentoDespesa,
            btMenuItemIncluirReceita,
            btMenuItemIncluirTransferencia,
            btMenuItemItensEstoque,
            btMenuItemItensPedidoCompra,
            btMenuItemNovaVenda,
            btMenuItemOperadoras,
            btMenuItemPedidosCompra,
            btMenuItemPermissoes,
            btMenuItemProdutos,
            btMenuItemReceitas,
            btMenuItemResgatarCreditos,
            btMenuItemSair,
            btMenuItemTarefas,
            btMenuItemTestarConexao,
            btMenuItemUsuarios,
            btNovaVenda
        };
        return itens;
    }

    public JDesktopPane getDesktopPane() {
        return this.desktopPane;
    }

}
